/**
 * author: zhangwei
 * 角色管理列表
 */
var main = {

    init: function() {
        this.initTable();
        this.tabBind();
    },
    initTable: function() {
        var _this=this;
        id = localStorage.id
        loadData(id)
        setVolunteerList(id)

    },
    tabBind: function() {


    }
}
main.init();

function loadData(id) {
    $.ajax({
        type:"get",
        async:false,
        url:'/college/getCollegeByName?collegeName='+id,
        success:function(result) {
            if (result.code == property.successCode) {
                var data = result.data
                $("#collegeName").text(data.collegeName)
                $("#collegeGuide").text(data.collegeGuide)
            } else{
                errorMsg(result.msg);
            }
        },
        error:function(result) {
            errorMsg("系统异常");
        }
    });
}

function getVolunteerList(id) {
    data = []
    $.ajax({
        type:"get",
        async:false,
        url:'/volunteer/queryVolunteerByCollege?college='+id,
        success:function(result) {
            if (result.code == property.successCode) {
                data = result.data
            } else{
                errorMsg(result.msg);
            }
        },
        error:function(result) {
            errorMsg("系统异常");
        }
    });
    return data
}

function setVolunteerList(id) {
    data = getVolunteerList(id)
    layui.use('table', function() {
        var table = layui.table;
        var form = layui.form;
        table.render({
            elem: '#test'
            ,data:data
            ,title: '医生数据表'
            ,cols: [[
                {type:'numbers', title:'序号', width:80, fixed: 'left', unresize: true, sort: true}
                ,{field:'volunteerName', title:'志愿者名称'}
                ,{field:'gender', title:'性别'}
                ,{field:'phone', title:'联系方式'}
                ,{field:'college', title:'所在院系'}
            ]]
            ,page: true
        });
    })

}

